﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Colorful.Control;
using System.Windows;
using Colorful.Control.Services;

namespace Colorful.Test.Unit
{
    [TestClass]
    public class CfXamlClipboardFormatterTest
    {
        [TestMethod]
        public void CopyPaletteTest()
        {
            var target = new CfXamlClipboardFormatter();
            var palette = new Palette();
            var dataObject = new DataObject();
            palette.Name = "My palette";
            target.AddToClipboard(dataObject, palette);
            Clipboard.SetDataObject(dataObject);
            Assert.IsTrue(Clipboard.GetDataObject().GetDataPresent((target.FormatName)));
        }

        [TestMethod]
        public void NumberInPaletteNameTest()
        {
            var target = new CfXamlClipboardFormatter();

            var input = new Palette();
            input.Name = "007 Colors";          
            string expected = "c007Colors";

            Assert.AreEqual<string>(expected, target.GetPaletteName(input));
        }

        [TestMethod]
        public void SpaceInPaletteNameTest()
        {
            var target = new CfXamlClipboardFormatter();

            var input = new Palette();
            input.Name = "My Super Color Name";
            string expected = "MySuperColorName";

            Assert.AreEqual<string>(expected, target.GetPaletteName(input));
        }

        [TestMethod]
        public void LeadingSpaceInPaletteNameTest()
        {
            var target = new CfXamlClipboardFormatter();

            var input = new Palette();
            input.Name = "  My Super Color Name  ";
            string expected = "MySuperColorName";

            Assert.AreEqual<string>(expected, target.GetPaletteName(input));
        }
    }
}